package primetest.faces;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;


import primetest.dto.BuildingDto;

public class BuildingListModel extends ListDataModel<BuildingDto> implements SelectableDataModel<BuildingDto> {

	public BuildingListModel(List<BuildingDto> buildingList){
		super(buildingList);
	}

	@Override
	public BuildingDto getRowData(String rowKey) {
		@SuppressWarnings("unchecked")
		List<BuildingDto> buildingList = (List<BuildingDto>)getWrappedData();
		for (BuildingDto buildingDto : buildingList) {
			if(buildingDto.getKey().equals(rowKey)){
				return buildingDto;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(BuildingDto buildingDto) {
		return buildingDto.getKey();
	}



}
